<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24" class="w400">
            <a-form-item label="报价人">
              <JSelectUserByDepCustom placeholder="请选择报价人" v-model="queryParam.bidder"></JSelectUserByDepCustom>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24" class="w400">
            <a-form-item label="负责人">
              <JSelectUserByDepCustom placeholder="请选择负责人" v-model="queryParam.directorIds"></JSelectUserByDepCustom>
            </a-form-item>
          </a-col>
          <template v-if="toggleSearchStatus">
            <a-col :xl="6" :lg="7" :md="8" :sm="24" class="w400">
              <a-form-item label="协同人">
                <JSelectUserByDepCustom placeholder="请选择协同人"
                                        v-model="queryParam.collaboratorIds"></JSelectUserByDepCustom>

              </a-form-item>
            </a-col>

          </template>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
              </a>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator flex-liangtou">
      <div>
        <a-button @click="handleAdd" type="primary" icon="plus">新建</a-button>
        <a-button type="primary" icon="download" @click="handleExportXls('报价单表')">导出</a-button>
        <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl"
                  @change="handleImportExcel">
          <a-button type="primary" icon="import">导入</a-button>
        </a-upload>
      </div>
      <div>
        <j-dict-select-tag placeholder="请选择归档" :value="filed" type="radioButton" dictCode="is_filed"
                           @change="filedChange" />
      </div>
    </div>

    <!-- table区域-begin -->
    <div>
      <div>
        <a-tabs default-active-key="0" @change="tabsChange">
          <a-tab-pane key="0" tab="全部" force-render></a-tab-pane>

          <a-tab-pane key="1" tab="今日新增"></a-tab-pane>
          <a-tab-pane key="2" tab="本周新增"></a-tab-pane>
          <a-tab-pane key="3" tab="我负责的"></a-tab-pane>
          <a-tab-pane key="4" tab="我协同的"></a-tab-pane>
          <a-tab-pane key="5" tab="下属负责的"></a-tab-pane>
          <a-tab-pane key="6" tab="下属协同的"></a-tab-pane>
        </a-tabs>
      </div>

      <a-table
        ref="table"
        size="middle"
        class="minH"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="opportunityId_dictText" slot-scope="text,record">
          <div class="table-warp">
            <a-tooltip>
              <template slot="title">
                {{ text }}
              </template>
              <a @click="seeJihui(record)">

                {{ text }}</a>
            </a-tooltip>

          </div>
        </template>
        <template slot="isRemind" slot-scope="text,record">
          <div @click="changeIsRemind(record)" class="follow-list-con">

            <a-popover
              title="跟进提醒内容"
              v-if="text==1"
              trigger="click"
              placement="right"
              :getPopupContainer=" triggerNode => {
 		return triggerNode.parentNode
 	}"
            >
              <template slot="content">
                <FollowList ref="FollowList" @ok="loadList" @yincang="yincang"></FollowList>
              </template>
              <a href="#">
                <a-icon type="bulb" theme="filled" style="color: #ff9f26;font-size: 20px;" />
              </a>
            </a-popover>
            <a-icon type="bulb" v-else style="font-size: 20px;color: #c6c6c6" />
          </div>


        </template>
        <template slot="name" slot-scope="text,record">
          <div class="table-warp">
            <a-tooltip>
              <template slot="title">
                {{ text }}
              </template>
              <a @click="handleDetail(record)">
                <a-tag color="cyan" v-if="record.filed==1">
                  归
                </a-tag>
                {{ text }}</a>
            </a-tooltip>

          </div>

        </template>
        <template slot="number" slot-scope="text,record">
          <a @click="handleDetail(record)">{{ text }}</a>
        </template>
        <template slot="customerId_dictText" slot-scope="text,record">
          <div class="table-warp">
            <a-tooltip>
              <template slot="title">
                {{ text }}
              </template>
              <a @click="seeCustomerId(record)">

                {{ text }}</a>
            </a-tooltip>

          </div>
        </template>
        <template slot="contactsIds_dictText" slot-scope="text,record">
          <a @click="seeLianxiren(record)">{{ text }}</a>
        </template>
        <template slot="state_dictText" slot-scope="text,record">
          <!--          1.报价中 2.已失效 3.已完成合同订单-->
          <a-tag color="purple" v-if="record.state==1">
            {{ text }}
          </a-tag>
          <a-tag color="red" v-if="record.state==2">
            {{ text }}
          </a-tag>
          <a-tag color="blue" v-if="record.state==3">
            {{ text }}
          </a-tag>
        </template>
        <!--        产品相关字段-->
        <template slot="chanpinname" slot-scope="text,record">
          <div class="table-warp">
            {{ record.productList.length > 0 ? record.productList[0].name : '' }}
            <a-popover trigger="click" class="chakanquanbu">
              <template slot="content">
                <a-table class="chanpin-table" :columns="seecolumns" :data-source="record.productList" size="middle"
                         bordered :scroll="{x:true}"
                         :pagination="false">

                </a-table>
              </template>
              <a-button type="link">
                查看全部
              </a-button>
            </a-popover>
          </div>
        </template>
        <!--        三元使用 为修正表格错位-->
        <template slot="chanpinnumber" slot-scope="text,record">
          <span>{{ record.productList.length > 0 ? record.productList[0].number : '' }}</span>
        </template>
        <template slot="specifications" slot-scope="text,record">
          <span>{{ record.productList.length > 0 ? record.productList[0].specifications : '' }}</span>
        </template>
        <template slot="barCode" slot-scope="text,record">
          <span>{{ record.productList.length > 0 ? record.productList[0].barCode : '' }}</span>
        </template>
        <template slot="unit" slot-scope="text,record">

          <div v-if="record.productList.length > 0">
            <j-dict-select-tag type="list" v-model="record.productList[0].unit" dictCode="product_unit" disabled
                               class="w100" />

          </div>
          <span v-else> </span>
        </template>
        <template slot="num" slot-scope="text,record">
          <span>{{ record.productList.length > 0 ? record.productList[0].num : '' }}</span>
        </template>
        <template slot="unitPrice" slot-scope="text,record">
          <span>{{ record.productList.length > 0 ? record.productList[0].unitPrice : '' }}</span>
        </template>
        <template slot="discount" slot-scope="text,record">
          <span>{{ record.productList.length > 0 ? record.productList[0].discount : '' }}</span>
        </template>
        <template slot="quotedPrice" slot-scope="text,record">
          <span>{{ record.productList.length > 0 ? record.productList[0].quotedPrice : '' }}</span>
        </template>
        <template slot="quotedPriceTotal" slot-scope="text,record">
          <span>{{ record.productList.length > 0 ? record.productList[0].quotedPriceTotal : '' }}</span>
        </template>
        <template slot="remarks" slot-scope="text,record">
          <span>{{ record.productList.length > 0 ? record.productList[0].remarks : '' }}</span>
        </template>

        <template slot="imgSlot" slot-scope="text,record">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt=""
               style="max-width:80px;font-size: 12px;font-style: italic;" />
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm v-has="'quotation:delete'" title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

      </a-table>
      <!--      底部功能区-->
      <!-- 操作按钮区域 -->
      <div class="table-caozuo-box">
        <div class="ant-alert ant-alert-info">
          <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a
          style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
          <a style="margin-left: 24px" @click="onClearSelected">清空</a>

          <a-button type="default" v-has="'quotation:transfer_user'"
                    @click="MAction(false,'/quotation/quotation/updateUserId',1,1260)">移交
          </a-button>

          <a-button type="default" @click="FollowRemind">跟进提醒</a-button>
          <a-button type="default" @click="MAction(false,'/quotation/quotation/updateDirector',2,1260)">添加负责人</a-button>
          <a-button type="default" @click="MAction(false,'/quotation/quotation/deleteDirector',2,1260)">删除负责人</a-button>
          <a-button type="default" @click="MAction(true,'/quotation/quotation/updateDirector',3,1260)">添加协同人</a-button>
          <a-button type="default" @click="MAction(true,'/quotation/quotation/deleteDirector',3,1260)">删除协同人</a-button>
          <a-button type="danger" @click="updateFile(1)" v-if="isFiledButtonShow">归档</a-button>
          <a-button type="danger" @click="updateFile(2)" v-else>取消归档</a-button>
          <a-button v-has="'quotation:batch_delete'" type="danger" @click="batchDel">删除</a-button>
        </div>

      </div>
    </div>

    <quartzJobModal ref="modalForm" @ok="modalFormOk"></quartzJobModal>
    <JSelectUserByDepModalCustom ref="MAmodel" :modalWidth="MAwidth" :multi="MAisMulti"
                                 @ok="MACallback"></JSelectUserByDepModalCustom>
    <FollowRemindModal ref="FollowRemindModal" @ok="modalFormOk"></FollowRemindModal>
    <CustomerModal ref="CustomerModal"></CustomerModal>
    <jihuiModal ref="jihuiModal"></jihuiModal>
    <contactsModalStyleDrawer ref="contactsModalStyleDrawer"></contactsModalStyleDrawer>
  </a-card>
</template>

<script>

import '@/assets/less/TableExpand.less'
import { underLinetoHump } from '@/components/_util/StringUtil'
import { getAction, postAction } from '@api/manage'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import JSelectUserByDepModalCustom from '@/components/jeecgbiz/modal/JSelectUserByDepModalCustom'
import JSelectUserByDepCustom from '@/components/jeecgbiz/JSelectUserByDepCustom'
import quartzJobModal from '@/views/QuotationList/modules/QuotationModal'
import { filterMultiDictText } from '@/components/dict/JDictSelectUtil'
import FollowRemindModal from '@/components/FollowRemind/modules/FollowRemindModal.Style#Drawer'
import CustomerModal from '@views/customer/modules/CustomerModal.Style#Drawer'
import contactsModalStyleDrawer from '@views/customer/modules/ContactsModal.Style#Drawer'

import FollowList from '@comp/FollowRemind/modules/FollowList'
import jihuiModal from '@/views/SalesOpportunintyList/modules/SalesOpportunintyModal.Style#Drawer'

export default {
  name: 'QuotationList',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    quartzJobModal,
    JSelectUserByDepModalCustom,
    JSelectUserByDepCustom,
    FollowRemindModal,
    CustomerModal,
    contactsModalStyleDrawer,
    FollowList,
    jihuiModal

  },
  data() {
    return {
      tabIndex: 0,
      tanVisible: false,
      followListShow: '',
      //名单选择时 多选还是单选
      MAisMulti: false,
      //选择名单回调接口
      MAcallBackUrl: '',
      //名单参数类型    1===移交 2===负责人 3协同人 4===分配
      MAtype: 0,
      //弹框宽度
      MAwidth: 1260,
      isFiledButtonShow: true,//归档 取消归档按钮
      filed: 0,//搜索区 归档默认值
      description: '报价单表管理页面',
      // 表头
      columns: [
        /* {
          title: '序号',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function(t, r, index) {
            return parseInt(index) + 1
          }
        }, */
        {
          title: '提醒',
          align: 'center',
          dataIndex: 'isRemind',
          width: 50,
          scopedSlots: { customRender: 'isRemind' }
        },
        {
          title: '编号',
          align: 'center',
          dataIndex: 'number',
          scopedSlots: { customRender: 'number' }

        },
        {
          title: '报价名称',
          align: 'center',
          dataIndex: 'name',
          scopedSlots: { customRender: 'name' }

        },
        {
          title: '客户',
          align: 'center',
          width: 200,
          dataIndex: 'customerIdDictText',
          scopedSlots: { customRender: 'customerId_dictText' }

        },
        {
          title: '联系人',
          align: 'center',
          dataIndex: 'contactsIdDictText',
          scopedSlots: { customRender: 'contactsIds_dictText' }

        },
        {
          title: '机会',
          align: 'center',
          width: 200,
          dataIndex: 'opportunityId_dictText',
          scopedSlots: { customRender: 'opportunityId_dictText' }

        },
        {
          title: '报价人',
          align: 'center',
          dataIndex: 'bidder_dictText'
        },
        {
          title: '报价时间',
          align: 'center',
          dataIndex: 'bidderTime'
        },
        {
          title: '有效日期',
          align: 'center',
          dataIndex: 'effectiveDate',
          customRender: function(text) {
            return !text ? '' : (text.length > 10 ? text.substr(0, 10) : text)
          }
        },
        {
          title: '状态',
          align: 'center',
          dataIndex: 'state_dictText',
          scopedSlots: { customRender: 'state_dictText' }
        },
        {
          title: '负责人',
          align: 'center',
          dataIndex: 'directorIds_dictText'
        },
        {
          title: '协同人',
          align: 'center',
          dataIndex: 'collaboratorIds_dictText'
        },
        {
          title: '产品',
          align: 'center',
          dataIndex: 'productIds_dictText',
          children: [
            {
              title: '产品名称',
              dataIndex: 'chanpinname',
              key: 'chanpinname',
              width: 200,
              scopedSlots: { customRender: 'chanpinname' }
            },
            {
              title: '产品编号',
              dataIndex: 'chanpinnumber',
              width: 200,
              key: 'chanpinnumber',
              scopedSlots: { customRender: 'chanpinnumber' }
            },
            {
              title: '规格',
              dataIndex: 'specifications',
              width: 150,
              key: 'specifications',
              scopedSlots: { customRender: 'specifications' }
            },
            {
              title: '产品条码',
              dataIndex: 'barCode',
              width: 150,
              key: 'barCode',
              scopedSlots: { customRender: 'barCode' }
            },
            {
              title: '报价单位',
              dataIndex: 'unit',
              key: 'unit',
              width: 150,
              scopedSlots: { customRender: 'unit' }
            },
            {
              title: '数量',
              dataIndex: 'num',
              key: 'num',
              width: 150,
              scopedSlots: { customRender: 'num' }
            },
            {
              title: '单价',
              dataIndex: 'unitPrice',
              key: 'unitPrice',
              width: 150,
              scopedSlots: { customRender: 'unitPrice' }
            },
            {
              title: '折扣(%)',
              dataIndex: 'discount',
              key: 'discount',
              width: 150,
              scopedSlots: { customRender: 'discount' }
            },
            {
              title: '报价',
              dataIndex: 'quotedPrice',
              key: 'quotedPrice',
              width: 150,
              scopedSlots: { customRender: 'quotedPrice' }
            },
            {
              title: '报价小计',
              dataIndex: 'quotedPriceTotal',
              key: 'quotedPriceTotal',
              width: 150,
              scopedSlots: { customRender: 'quotedPriceTotal' }
            },
            {
              title: '备注',
              dataIndex: 'remarks',
              key: 'remarks',
              width: 150,
              scopedSlots: { customRender: 'remarks' }
            }
          ]
        },
        {
          title: '产品合计',
          align: 'center',
          dataIndex: 'totalProducts'
        },
        {
          title: '折扣率',
          align: 'center',
          dataIndex: 'discountRate'
        },
        {
          title: '其他费用',
          align: 'center',
          dataIndex: 'otherExpenses'
        },
        {
          title: '优惠价钱',
          align: 'center',
          dataIndex: 'preferentialAmount'
        },
        {
          title: '报价金额',
          align: 'center',
          dataIndex: 'quotationAmount'
        },
        {
          title: '创建时间',
          dataIndex: 'createTime',
          key: 'createTime',
          width: 150
        },
        {
          title: '创建人',
          dataIndex: 'createBy',
          key: 'createBy'
        },
        {
          title: '更新时间',
          dataIndex: 'updateTime',
          key: 'updateTime'
        },
        /* {
          title: '归档',
          align: 'center',
          dataIndex: 'filed_dictText'
        }, */
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 147,
          scopedSlots: { customRender: 'action' }
        }
      ],
      seecolumns: [
        {
          title: '产品名称',
          dataIndex: 'name',
          key: 'name',
          width: 200,
          scopedSlots: { customRender: 'name' }
        },
        {
          title: '产品编号',
          dataIndex: 'number',
          width: 200,
          key: 'number',
          scopedSlots: { customRender: 'number' }
        },
        {
          title: '规格',
          dataIndex: 'specifications',
          width: 150,
          key: 'specifications',
          scopedSlots: { customRender: 'specifications' }
        },
        {
          title: '产品条码',
          dataIndex: 'barCode',
          width: 150,
          key: 'barCode',
          scopedSlots: { customRender: 'barCode' }
        },
        {
          title: '报价单位',
          dataIndex: 'unit',
          key: 'unit',
          width: 150,
          scopedSlots: { customRender: 'unit' }
        },
        /* {
          title: '分类',
          dataIndex: 'type',
          key: 'type',
          width: 150,
          scopedSlots: { customRender: 'type' }
        }, */
        {
          title: '数量',
          dataIndex: 'num',
          key: 'num',
          width: 150,
          scopedSlots: { customRender: 'num' }
        },
        {
          title: '单价',
          dataIndex: 'unitPrice',
          key: 'unitPrice',
          width: 150,
          scopedSlots: { customRender: 'unitPrice' }
        },
        {
          title: '折扣(%)',
          dataIndex: 'discount',
          key: 'discount',
          width: 150,
          scopedSlots: { customRender: 'discount' }
        },
        {
          title: '报价',
          dataIndex: 'quotedPrice',
          key: 'quotedPrice',
          width: 150,
          scopedSlots: { customRender: 'quotedPrice' }
        },
        {
          title: '报价小计',
          dataIndex: 'quotedPriceTotal',
          key: 'quotedPriceTotal',
          width: 150,
          scopedSlots: { customRender: 'quotedPriceTotal' }
        },
        {
          title: '备注',
          dataIndex: 'remarks',
          key: 'remarks',
          width: 150,
          scopedSlots: { customRender: 'remarks' }
        }
        /* {
          title: '操作',
          dataIndex: 'operation',
          key: 'operation',
          width: 100,
          fixed: 'right',
          scopedSlots: { customRender: 'operation' }
        } */
      ],
      url: {
        jihuiList: '/sales/salesOpportuninty/list',
        contactsIds: '/contacts/contacts/queryById',
        customList: '/customer/customer/list',
        list: '/quotation/quotation/list',
        delete: '/quotation/quotation/delete',
        deleteBatch: '/quotation/quotation/deleteBatch',
        exportXlsUrl: '/quotation/quotation/exportXls',
        importExcelUrl: 'quotation/quotation/importExcel',
        updateUserId: '/quotation/quotation/updateUserId',//移交
        updateDirector: '/quotation/quotation/updateDirector'//添加删除负责人、协同人
      },
      dictOptions: {},
      superFieldList: []
    }
  },
  created() {
    this.getSuperFieldList()
    // this.queryParam.filed = 0
  },
  computed: {
    importExcelUrl: function() {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    }

  },
  methods: {
    //重置
    searchReset() {

      this.queryParam = {}
      this.queryParam.filed = this.filed
      this.queryParam.statusTop = this.tabIndex
      if (this.filed == 1) {
        this.isFiledButtonShow = false

      } else {
        this.isFiledButtonShow = true
      }
      this.loadData(1)
    },
    handleEdit: function(record) {
      this.$refs.modalForm.edit(record)
      this.$refs.modalForm.title = '编辑'
      this.$refs.modalForm.disableSubmit = false
      // this.$refs.modalForm.changeUrl()
    },

    getSuperFieldList() {
      let fieldList = []
      fieldList.push({ type: 'string', value: 'number', text: '编号', dictCode: '' })
      fieldList.push({ type: 'string', value: 'name', text: '报价名称', dictCode: '' })
      fieldList.push({
        type: 'sel_search',
        value: 'customerId',
        text: '客户ID',
        dictTable: 'biz_customer',
        dictText: 'name',
        dictCode: 'id'
      })
      fieldList.push({
        type: 'list_multi',
        value: 'contactsIds',
        text: '联系人IDS',
        dictTable: 'biz_contacts',
        dictText: 'name',
        dictCode: 'id'
      })
      fieldList.push({
        type: 'sel_search',
        value: 'opportunityId',
        text: '机会ID',
        dictTable: 'biz_sales_opportuninty',
        dictText: 'name',
        dictCode: 'id'
      })
      fieldList.push({ type: 'string', value: 'bidder', text: '报价人', dictCode: '' })
      fieldList.push({ type: 'datetime', value: 'bidderTime', text: '报价时间' })
      fieldList.push({ type: 'date', value: 'effectiveDate', text: '有效日期' })
      fieldList.push({ type: 'int', value: 'state', text: '状态(1.报价中 2.已失效 3.已完成合同订单)', dictCode: 'quotation_state' })
      fieldList.push({ type: 'sel_user', value: 'directorIds', text: '负责人IDS' })
      fieldList.push({ type: 'sel_user', value: 'collaboratorIds', text: '协同人IDS' })
      fieldList.push({
        type: 'list_multi',
        value: 'productIds',
        text: '产品IDS',
        dictTable: 'biz_product',
        dictText: 'name',
        dictCode: 'id'
      })
      fieldList.push({ type: 'BigDecimal', value: 'totalProducts', text: '产品合计', dictCode: '' })
      fieldList.push({ type: 'string', value: 'discountRate', text: '折扣率', dictCode: '' })
      fieldList.push({ type: 'BigDecimal', value: 'otherExpenses', text: '其他费用', dictCode: '' })
      fieldList.push({ type: 'BigDecimal', value: 'preferentialAmount', text: '优惠价钱', dictCode: '' })
      fieldList.push({ type: 'BigDecimal', value: 'quotationAmount', text: '报价金额', dictCode: '' })
      fieldList.push({ type: 'int', value: 'filed', text: '归档', dictCode: 'is_filed' })
      this.superFieldList = fieldList
    },
    /* yijiao(){
      if (this.selectedRowKeys.length <= 0) {
        this.$message.warning('未选中任何数据！');
        return;
      }
      this.$refs.selectModal.showModal()
    }, */
    MAction(MAisMulti, MAcallBackUrl, MAtype, MAwidth) {
      //Member action
      //设置多选还是单选
      // this.MAisMulti = false
      this.MAisMulti = MAisMulti
      //设置回调接口
      // this.MAcallBackUrl  = '/quotation/quotation/updateDirector'
      this.MAcallBackUrl = MAcallBackUrl
      //设置回调接口参数
      // this.MAtype = 1
      this.MAtype = MAtype
      //弹框宽度
      // this.MAwidth = 1260
      this.MAwidth = MAwidth
      if (this.selectedRowKeys.length <= 0) {
        this.$message.warning('请至少或者最多选择一条记录！')
        return
      }
      this.$refs.MAmodel.showModal()
    },
    MACallback(e) {
      this.loading = true
      console.log('e', e)
      console.log('this.selectedRowKeys', this.selectedRowKeys)
      let ids = this.selectedRowKeys.join(',')
      let obj = {}
      switch (this.MAtype) {
        case 1://移交
          obj = { id: ids, userId: e[0].id }
          break
        case 2://负责人
          obj = { id: ids, directorIds: e[0].id }
          break
        case 3://协同人
          let arr2 = []
          e.forEach(res => {
            arr2.push(res.id)
          })
          obj = { id: ids, collaboratorIds: arr2.join(',') }
          break
        case 4://分配
          obj = { id: ids, directorIds: e[0].id }
          break

      }
      postAction(this.MAcallBackUrl, obj).then(res => {
        console.log('移交后', res)
        if (res.success) {
          this.selectedRowKeys = []
          this.$message.success(res.message)
          this.loading = false
          this.loadData()
        } else {
          this.$message.error(res.message)
          this.loading = false
          // this.loadData()
        }

      })
    },
    //归档
    updateFile(index) {
      // 1===归档  2===取消归档

      if (this.selectedRowKeys.length <= 0) {
        this.$message.error('请至少或者最多选择一条记录！')
        return
      }
      if (index == 1) {
        this.loading = true
        this.$confirm({
          title: '归档确定',
          content: '确认归档这' + this.selectedRowKeys.length + '个报价单吗?',
          okText: '确定',
          cancelText: '取消',
          onOk: () => {
            console.log('OK')
            let ids = this.selectedRowKeys.join(',')
            postAction('/quotation/quotation/updateFiled', { id: ids }).then(res => {
              console.log('归档', res)
              if (res.success) {
                this.$message.success(res.message)
              } else {
                this.$message.error(res.message)
              }
            }).finally(() => {
              this.loading = false
              this.loadData()
            })
          },
          onCancel: () => {
            this.loading = false
            console.log('Cancel')
          }
        })
      } else {
        this.loading = true
        this.$confirm({
          title: '归档取消',
          content: '确认取消归档这' + this.selectedRowKeys.length + '个报价单吗?',
          okText: '确定',
          cancelText: '取消',
          onOk: () => {
            console.log('OK')
            let ids = this.selectedRowKeys.join(',')
            postAction('/quotation/quotation/updateCancelFiled', { id: ids }).then(res => {
              console.log('归档', res)
              if (res.success) {
                this.$message.success(res.message)
              } else {
                this.$message.error(res.message)
              }
            }).finally(() => {
              this.loading = false
              this.loadData()
            })
          },
          onCancel: () => {
            this.loading = false
            console.log('Cancel')
          }
        })
      }

    },
    //搜索
    searchQuery() {
      console.log('this.queryParam', this.queryParam)
      if (this.queryParam.filed == 1) {
        this.isFiledButtonShow = false
      } else {
        this.isFiledButtonShow = true
      }
      this.loadData(1)
      // 点击查询清空列表选中行
      // https://gitee.com/jeecg/jeecg-boot/issues/I4KTU1
      this.selectedRowKeys = []
      this.selectionRows = []
    },
    //重置
    /* searchReset() {
      this.isFiledButtonShow = true
      this.queryParam = {}
      this.loadData(1)
    }, */
    //搜索框归档改变
    filedChange(e) {
      console.log('e', e)
      if (e == 1) {
        this.isFiledButtonShow = false
      } else {
        this.isFiledButtonShow = true
      }
      this.filed = e
      this.queryParam.filed = e
      this.loadData()
    },
    //跟进提醒
    FollowRemind() {
      if (this.selectedRowKeys.length <= 0) {
        this.$message.error('请至少或者最多选择一条记录！')
        return
      }
      let followIdArr = []
      let customer_idArr = []
      this.dataSource.forEach(res => {
        if (this.selectedRowKeys.includes(res.id)) {
          followIdArr.push(res.number)
          customer_idArr.push(res.customerId)
        }
      })
      console.log('followIdArr', followIdArr)
      let record = {
        followIdArr: followIdArr,
        title: followIdArr[0] + '等' + followIdArr.length + '个报价单的跟进提醒',
        type: 3,//传跟进类型
        numberType: '编号',
        businessId: this.selectedRowKeys.join(','),
        customerId: customer_idArr.join(',')
      }

      this.$refs.FollowRemindModal.add(record)
      this.$refs.FollowRemindModal.followShow = true
    },
    //查看客户详情
    seeCustomerId(record) {
      this.loading = true
      getAction(this.url.customList, { id: record.customerId }).then(res => {
        if (res.success) {
          this.$refs.CustomerModal.dongtai(record.customerId)
          this.$refs.CustomerModal.dongtaiShow = true
          this.$refs.CustomerModal.edit(res.result.records[0])
          this.$refs.CustomerModal.disableSubmit = true
        } else {
          this.$message.error(res.message)
        }
      }).finally(() => {
        this.loading = false
      })

    },
    //查看销售机会
    seeJihui(record) {
      let opportunityId = record.opportunityId
      console.log('opportunityId', opportunityId)
      console.log('opportunityId', typeof opportunityId)
      this.loading = true
      getAction(this.url.jihuiList).then(res => {
        if (res.success) {
          console.log('res.result.records', res.result.records)
          let target = res.result.records.find((item) => item.id == opportunityId
          )
          console.log('target', target)
          // this.$refs.jihuiModal.dongtai(record.customerId)
          // this.$refs.jihuiModal.dongtaiShow = true
          this.$refs.jihuiModal.edit(target)
          this.$refs.jihuiModal.disableSubmit = true
        } else {
          this.$message.error(res.message)
        }
      }).finally(() => {
        this.loading = false
      })
    },
    //查看联系人详情
    seeLianxiren(record) {
      this.loading = true
      getAction(this.url.contactsIds + '?id=' + record.contactsIds).then(res => {
        if (!res.result) {
          this.$message.error('无权查看')
          return false
        }
        if (res.success) {
          this.$refs.contactsModalStyleDrawer.edit(res.result)
          this.$refs.contactsModalStyleDrawer.disableSubmit = true
        } else {
          this.$message.error(res.message)
        }
      }).finally(() => {
        this.loading = false
      })

    },
    //提醒
    changeIsRemind(res) {
      console.log(res)
      //判断状态  标记isAdd是新增状态 需要在form里判断 是新增还是编辑
      if (res.isRemind == 0) {
        let record = {
          followIdArr: [res.name],
          title: res.name + '报价单的跟进提醒',
          type: 3,//传跟进类型
          numberType: '编号',
          businessId: res.id,
          customerId: res.id,
          isAdd: true
        }
        this.$refs.FollowRemindModal.add(record)
        this.$refs.FollowRemindModal.followShow = true
      } else {
        //弹出提醒列表
        let obj = Object.assign(res, { type: 3 })
        this.$refs.FollowList.getID(obj)

      }
    },
    //跟进提醒的刷新列表
    loadList() {
      this.loadData()
    },
    //tab页查询
    tabsChange(e) {
      this.tabIndex = e
      console.log(e)
      if (e == 0) {
        this.queryParam = {}
        this.queryParam.filed = this.filed
        this.loadData()
      } else {
        this.queryParam.statusTop = e
        this.loadData()
      }

    },
    //隐藏提醒列表
    yincang() {
      this.tanVisible = false
    }

  }
}
</script>
<style scoped lang="less">
@import '~@assets/less/common.less';

.table-caozuo-box {
  button {
    margin-left: 10px;
  }
}

/deep/ .ant-popover {
  z-index: 800 !important;
}

.w400 {
  width: 400px;
}

.table-warp {
  width: 100%;
  word-break: break-all;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1; /* 这里是超出几行省略 */
  overflow: hidden;
  position: relative;
}

.chakanquanbu {
  transition: all 0.3s ease-out;
  opacity: 0;
  position: absolute;
  right: -16px;
  top: -4px;
  background: #e6f7ff;
}

/deep/ .ant-table-tbody > tr:hover:not(.ant-table-expanded-row):not(.ant-table-row-selected) > td {
  .chakanquanbu {
    opacity: 1;
  }
}

.chanpin-table {
  width: 800px;
}

.chakanquanbu {
  transition: all 0.3s ease-out;
  opacity: 0;
  position: absolute;
  right: -16px;
  top: -4px;
  background: #e6f7ff;
}


/*默认表格高度 撑起空白*/
/deep/ .minH .ant-table-body {
  min-height: 400px;
  //border-left: 1px solid #e8e8e8;
  //border-right: 1px solid #e8e8e8;
}

.ant-table table {
  table-layout: fixed;
}

.flex-liangtou {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
}

.w100 {
  width: 100%;
}
</style>